package com.tangsm.spring.boot.springdoc.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 用户信息
 *
 * @author tangsm
 * @date 2021-07-27 10:45:02
 */
@Schema(name = "User", description = "用户信息")
public class User implements Serializable {

    public User(Long id, String name, LocalDate birthday, Integer age, BigDecimal money) {
        this.id = id;
        this.name = name;
        this.birthday = birthday;
        this.age = age;
        this.money = money;
    }

    /**
     * 用户ID
     */
    @Schema(name = "id", description = "用户ID")
    private Long id;

    /**
     * 姓名
     */
    @NotNull
    @Schema(name = "name", description = "姓名", required = true)
    private String name;

    /**
     * 生日
     */
    @NotNull(message = "生日[birthday]不能为空")
    @Schema(name = "birthday", description = "生日", required = true)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthday;

    /**
     * 年龄
     */
    @Max(200)
    @Min(1)
    @Schema(name = "age", description = "年龄", required = true)
    private Integer age;

    /**
     * 账户余额
     */
    @Min(1)
    @Schema(name = "money", description = "账户余额", required = true)
    private BigDecimal money;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", birthday=" + birthday +
                ", age=" + age +
                ", money=" + money +
                '}';
    }
}
